﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using messageboard.bll;

namespace messageboard.admin
{
    public partial class usermanage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {   //判断是否管理员登录
            if (Session["name"]==null)
            {
                Label1.Text = "您无权查看该网页";
                login.Visible = true;
            }
          /*  else if (Session["name"].ToString() != "admin")
            {
                Label1.Text = "您无权查看该网页";
                login.Visible = true;
                
            }*/

           else if (!IsPostBack)
            {   //数据绑定
                login.Visible = false;
                GridView1.DataSource = new UserBll().getalluser();
                GridView1.DataBind(); 
            }
            
        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //删除操作
            string a = GridView1.DataKeys[e.RowIndex].Value.ToString();
            UserBll userbll = new UserBll();
            userbll.deleteuser(a);
            
            Response.Redirect("usermanage.aspx");
          
        }

        protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
        {
            Label1.Text = "删除成功";
            
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {   //PageIndexChanging事件
            GridView1.PageIndex = e.NewPageIndex;
            GridView1.DataSource = new UserBll().getalluser();
            DataBind();
        }

       

       
    }
}